package com.mazaiting;

import lombok.extern.slf4j.Slf4j;

/**
 * 应用启动类
 * 测试参数:
 *  -help
 *  -version
 *  -cp foo/bar MyApp arg1 arg2
 * @author mazaiting
 * @since 2021/8/10
 */
@Slf4j
public class SJava {
    public static void main(String[] args) {

        Cmd cmd = Cmd.parseCmd(args);
        if (cmd.isVersionFlag()) {
            System.out.println("version 0.0.1");
        } else if (cmd.isHelpFlag()) {
            log.info("Usage: {} [-options] class [args...]", SJava.class.getSimpleName());
        } else {
            startJVM(cmd);
        }
    }

    /**
     * 启动 JVM
     * @param cmd 命令行参数
     */
    private static void startJVM(Cmd cmd) {
        log.info("classpath:{} class:{} args:{}\n", cmd.getCpOption(), cmd.getClassName(), cmd.getArgs());
    }
}


















